Device profiling in gpu accelerators by using host-device coordination

ABSTRACT

System and method of compiling a program having a mixture of host code and device code to enable Profile Guided Optimization (PGO) for device code execution. An exemplary integrated compiler can compile source code programmed to be executed by a host processor (e.g., CPU) and a co-processor (e.g., a GPU) concurrently. The compilation can generate an instrumented executable code which includes: profile instrumentation counters for the device functions; and instructions for the host processor to allocate and initialize device memory for the counters and to retrieve collected profile information from the device memory to generate instrumentation output. The output is fed back to the compiler for compiling the source code a second time to generate optimized executable code for the device functions defined in the source code.

CROSSREFERENCE TO RELATED PATENT APPLICATION

This application is a continuation of U.S. patent application Ser. No.16/154,560, filed Oct. 8, 2018 which claims priority to, and benefit of,U.S. Provisional Patent Application No. 62/569,380, filed on Oct. 6,2017, and entitled “COORDINATED HOST DEVICE MECHANISM FOR DEVICEPROFILING IN GPU ACCELERATORS AND CODE COVERAGE IN GPU ACCELERATORS FORWHOLE PROGRAM AND SEPARATE COMPILATION.” Each of these applications isherein incorporated by reference in its entirety. This application isrelated to the co-pending, commonly-assigned U.S. patent applicationSer. No. 16/154,542, filed on Oct. 8, 2018, and entitled “CODE COVERAGEGENERATION IN GPU BY USING HOST-DEVICE COORDINATION.”

FIELD OF THE INVENTION

Embodiments of the present disclosure are related to computer programcompilers, and more specifically, to optimizing compilers of software tobe performed by one or more co-processors by coordinating with one ormore host processors.

BACKGROUND OF THE INVENTION

Compiler optimization techniques typically use code instrumentationtechniques for software programs that are to be performed by a hostprocessor, such as a central processing unit (CPU). However, currentcompiler optimization techniques are not able to optimize code intendedto be performed by co-processors, such as a graphics processing unit(GPU) or other fixed-function accelerator due, in part, to thedifficulty in coordinating between a host processor (e.g., CPU) and aco-processor (e.g., GPU) when instrumenting code to be performed by theco-processor. Accordingly, there is a currently a need for techniques tooptimize code to be performed by a co-processor, such as a GPU or otheraccelerator.

BRIEF DESCRIPTION OF THE DRAWINGS

Embodiments are illustrated by way of example, and not by way oflimitation, in the figures of the accompanying drawings.

FIG. 1 illustrates a PGO flow using an exemplary integrated compiler tocompile source code of a program having a mixture of host code anddevice code in accordance with an embodiment of the present disclosure.

FIG. 2A illustrates an exemplary computer implemented process ofinstrumented compilation and execution to generate the profileinformation from device code execution in accordance with an embodimentof the present disclosure.

FIG. 2B is a flow chart depicting an exemplary computer implementedprocess of profile instrument generation in the instrumented compilationphase in accordance with an embodiment of the present disclosure.

FIG. 2C is a flow chart depicting an exemplary instrumented executionprocess through coordination between a CPU and a GPU in accordance withan embodiment of the present disclosure.

FIG. 3A illustrates an exemplary computer implemented process ofoptimization compilation to generate optimized executable code based oncollected profile information in accordance with an embodiment of thepresent disclosure.

FIG. 3B is a flow chart depicting an exemplary computer implementedprocess of processing instrumentation output by a profiler pass in theoptimization compilation phase in accordance with an embodiment of thepresent disclosure.

FIG. 4 is a block diagram illustrating an exemplary computing systemoperable to compile integrated source code and thereby generateinstrumented executable code and optimized executable code for devicecode execution in accordance with an embodiment of the presentdisclosure.

DETAILED DESCRIPTION OF THE INVENTION

Reference will now be made in detail to the embodiments of the presentdisclosure, examples of which are illustrated in the accompanyingdrawings. It will be understood that they are not intended to limit tothese embodiments. On the contrary, the disclosed is intended to coveralternatives, modifications and equivalents, which may be includedwithin the spirit and scope of the disclosure as defined by the appendedclaims. Furthermore, in the following detailed description ofembodiments, numerous specific details are set forth in order to providea thorough understanding. However, it will be recognized by one ofordinary skill in the art that the present disclosure may be practicedwithout these specific details. In other instances, well-known methods,procedures, components, and circuits have not been described in detailas not to unnecessarily obscure aspects of the embodiments of thepresent disclosure.

Notation And Nomenclature

Some portions of the detailed descriptions, which follow, are presentedin terms of procedures, steps, logic blocks, processing, and othersymbolic representations of operations on data bits within a computermemory. These descriptions and representations are the means used bythose skilled in the data processing arts to most effectively convey thesubstance of their work to others skilled in the art. A procedure,computer executed step, logic block, process, etc., is here, andgenerally, conceived to be a self-consistent sequence of steps orinstructions leading to a desired result. The steps are those requiringphysical manipulations of physical quantities. Usually, though notnecessarily, these quantities take the form of electrical or magneticsignals capable of being stored, transferred, combined, compared, andotherwise manipulated in a computer system. It has proven convenient attimes, principally for reasons of common usage, to refer to thesesignals as bits, values, elements, symbols, characters, terms, numbers,or the like.

It should be borne in mind, however, that all of these and similar termsare to be associated with the appropriate physical quantities and aremerely convenient labels applied to these quantities. Unlessspecifically stated otherwise as apparent from the followingdiscussions, it is appreciated that throughout the present disclosure,discussions utilizing terms such as “processing” “compiling” “linking”or “accessing” or “performing” or “executing” or “providing” or thelike, refer to the action and processes of an integrated circuit, orsimilar electronic computing device, that manipulates and transformsdata represented as physical (electronic) quantities within the computersystem's registers and memories into other data similarly represented asphysical quantities within the computer system memories or registers orother such information storage, transmission or display devices.

Device Profiling in GPU Accelerators by using Host-Device Coordination

Embodiments of the present disclosure provide a compilation mechanism toenable generation of profile information with regard to co-processor (ordevice processor or accelerator processor herein) code execution, andthe profile information can be used for Profile Guided Optimization(PGO). An exemplary integrated compiler can compile source codeprogrammed to be concurrently executed by a main processor (or hostprocessor) and a co-processor. The compilation can generate aninstrumented executable code which includes: profile instrumentationcounters for the device functions; and instructions for the hostprocessor to allocate and initialize device memory for the counters andto retrieve collected profile information from the device memory togenerate instrumentation output. The output is fed back to the compilerfor compiling the source code a second time to generate optimizedexecutable code.

As the performance of device code is critical to high performancecomputing and machine learning communities, significant performancebenefits can be advantageously obtained by using compilationoptimizations of the embodiments of the present disclosure based on thereliable profile information.

In one embodiment, a first processor, such as a GPU operates, as aco-processor of a second processor, such as a CPU, or vice versa. Thefirst processor and the second professor are configured to operate in aco-processing manner.

Some embodiments of the present disclosure can be integrated in a NVCCcompiler for the CUDA programming language and a General-Purposecomputing on Graphics Processing Units (GPGPU) platform, e.g., with aCPU being the host and a GPU being a device. However, other embodimentsof the present disclosure may also be used in any other suitableparallel computing platform that includes different types of processors.

For example, an application program written for CUDA may includesequential C language programming statements, and calls to a specializedapplication programming interface (API) used for configuring andmanaging parallel execution of program threads. A function associatedwith a CUDA application program that is destined for concurrentexecution on a device processor is referred to as a “kernel” function.An instance of a kernel function is referred to as a thread, and a setof concurrently executing threads may be organized as a thread block.

FIG. 1 illustrates the PGO flow 100 by using an exemplary integratedcompiler 112 to compile source code (e.g., CUDA) of a program having amixture of host code and device code (e.g., mainly GPU functions) inaccordance with an embodiment of the present disclosure. In oneembodiment, the device code is typically mainly composed of GPUfunctions; the host code may be written in C++ for example and includesGPU function calls. The PGO process includes 3 phases: instrumentedcompilation 110, instrumented execution 120 and optimization compilation130. The compiler 112 includes a profile instrument generation module114 and a profile instrument use module 134.

In one embodiment, in the instrumented compilation phase 110, thecompiler 112 compiles the source code to generate instrumentedexecutable code. The profile instrument generation module 114 generatesa Control Flow Graph (CFG) according to the GPU functions and insertsprofile counters to the code to instrument the edges and basic blocks ofthe CFG. In the instrumented execution phase 120, a representative inputset is provided for execution, which typically corresponds to arepresentative case. The host and the device execute the instrumentedexecutable code and produce and store a profile file containingcollected profile information. During the execution phase 120, a counterfor a respective edge or block is updated each time the edge or block isencountered during execution. In this fashion, the counters recordexecution performance information regarding the various portions of thesource code.

In the optimization compilation phase 130, the profile file is fed backto the compiler 112 for a second compilation on the source code, and theprofile guided use module 134 performs a code optimization process basedon the profile file, particularly device code optimization. As a result,an optimized executable code version is generated which can then beexecuted with a use case input set. As the performance of device code iscritical to high performance computing, such as in the machine learningcommunities, significant performance benefits can be advantageouslyobtained by using compilation optimizations based on the reliableprofile information.

As the profile information collected for a program is sensitive tochanges to the compiler and the source code, it is important that theprofile optimization phase 130 uses the correct profile informationcorresponding to the source file being compiled in the instrumentedcompilation phase 110 and executed in the instrumented execution phase120. To this effect, in one embodiment, a Cyclic Redundancy Check (CRC)error detection code can be used to check based on the structure andindexes of the CFG of the program. The CRC code in combination with thefunction names can be used to verify the validity of profile data fromcollection to use phase.

FIG. 2A illustrates an exemplary computer implemented process 200 ofinstrumented compilation and execution to generate the profileinformation of device code execution in accordance with an embodiment ofthe present disclosure. In one embodiment, the instrumented compilationprocess may be performed by an exemplary compiler that integrates thefunctionalities of host compilation, device compilation, and linking.

More specifically, the integrated source code is processed by thepreprocessors 211 and 212, and the device code and the host code areseparated from each other and supplied to the device compiler 226 andthe host compiler 213, respectively. In the device compiler, the devicecode is then subject to front end processing 228, optimization phaseprocessing 222, and back end processing 224 to generate device codemachine binary. In the illustrated embodiments, as shown in FIGS. 2A and3A, a profiler pass 223 is implemented in the device optimization phase222 and used in both profile instrumentation generation in theinstrumented compilation phase and profile guided use in the optimizedcompilation phase. In one embodiment, the profiler pass 223 is a modulepass integrated as part of an Intermediate Representation (IR) pass inthe device optimization phase 222, and can be invoked anywhere in theoptimization pipeline of the device back end 224 before conversion ofthe IR code to the machine binary code. However, it will be appreciatedthat the device profile generation and use functionalities can beimplemented in any other well-known suitable manner without departingfrom the scope of the present disclosure.

As described in greater detail below with reference to FIGS. 2B and 2C,in one embodiment, the profiler pass 223 is configured to generatedevice instrumentation code for the device functions, which code isincluded in the IR code output from the device optimization phase 222.The IR code is converted to machine binary through the back endprocessing.

According to one embodiment of the present disclosure, the profiler pass223 can generate a CFG for the device code and insert profile countersto instrument the edges and basic blocks of the CFG, thereby producingdevice instrument code. Besides the device function calls, the deviceinstrument code specifies the profile counters defined for the CFG andincludes instructions for a device processor to update the profilecounters. The counters are updated each time the associated code isexecuted. Also generated are the instructions for coordination betweenthe host processor and the device processor, such as memory allocationand initialization. In one embodiment, the instructions are enclosed ina “profinfo” file.

The device instrument code is enclosed in the IR code output from thefront end 222. The IR code is then converted to machine binary throughthe back end processing. The device instrument code is embedded (e.g.,as fat binary images) in the front end-processed host code forcompilation by the host compiler 213 to generate an object file. In oneembodiment, provided with the device instrument code and the “profinfo”file, the host compiler 213 can generate instructions for a hostprocessor to allocate and initialize memory for the counters in theinstrumented execution phase, as described in greater detail below withreference to FIGS. 2B-2C. The object file is then processed by thedevice linker 231 (in case of separate compilation as described below),the host compiler 213, and the host linker 232. As a result, theinstrumented executable code is generated for the program. After theexecution platform 240 executes the executable, an instrumentationoutput with the collected profile information is produced, as describedin greater detail with reference to FIG. 2C.

In one embodiment, the flow in the dashed-line box 220 may be performedfor each virtual architecture, e.g., each Instruction Set Architecture(ISA). For example, CUDA uses a virtual ISA called Parallel ThreadExecution (PTX). PTX ISA has improved over time in conjunction withchanges to any hardware capabilities. A CUDA library designed to run onmultiple GPU architectures will typically be compiled for eacharchitecture separately and bundled together in a file (e.g., “fatbin”).In one embodiment, in a CUDA program, the user can use macros to checkfor the architecture and diverge on functionality based on thearchitecture. In some embodiments, an architecture field is added to thehost-device communication macros to uniquely identify the differentarchitecture variants.

Generally, for a host processor to perform memory allocation andinitialization before launching a kernel, a complete set of devicefunctions directly or indirectly called by a kernel is needed. In oneembodiment, in case of whole compilation, the flow in the dashed-linebox 210 is performed once as the device instrument code supplied to thehost compiler includes a complete function call list (callee list) ofeach kernel.

However, in case of separate compilation, a complete function call listof a kernel may not be known at the time of compiling the kernel by thedevice compiler 226. The call graph and the callee list may be onlyavailable at link time. In one embodiment, communications between thedevice compiler 226, the linker 231 and the host compiler 213 are usedto achieve instrumentation. Partial instrument information from allcompilation units is fed to the linker 231 and combined with the objectfile. As such, the instrumentation for the entire program, and thereforefor a complete function call list, becomes available. In one embodiment,some runtime libraries may be added for supporting remotesingle-program-multiple-data procedure calling and for providingexplicit device manipulation such as allocation of device memory buffersand host-device data transfer.

More specifically, for each compilation unit configured to compile aportion of the source code, the flow in the dashed-line box 210 isperformed once and the profiler pass 223 may generate instrumentationrelated to a partial function call list contained in the portion. Duringcompilation, the device compiler 226 instruments the code as it wouldfor a whole program compilation. In one embodiment, in addition, itemits certain instrument information to the host compiler 213 for thehost compiler to declare mirrors for the profile counters.

In one embodiment, an initialized constant variable may be created,containing: 1. Function name, function hash, architecture ID and numberof counters for each function; and 2. Partial call list containing callsrecognized for one compilation unit.

In one embodiment, at link time, the instrument information from allcompilation units is collated and a call graph is generated whichcontains the partial call graphs using compiler information. This callgraph is supplemented with the call graph generated by the linker 231,and instrument code is generated using the combined call list. Thisinstrument code contains all the information necessary for the host sideto allocate memory and print profile to a file after a kernel launch. Ahost side profile stub file is created, compiled and linked to producethe final executable.

In one embodiment, function names may be passed between the devicecompiler 226 and the device linker 231 using relocations. The devicecompiler 226 uses function addresses in the counter variableinitialization. They turn into linker relocations, which are patched atlink time. In another embodiment, function names can be passed asstrings.

As the profile information collected for a program is sensitive tochanges to the compiler and the source code, it is important that theprofile optimization phase 130 uses the correct profile informationcorresponding to the source file being compiled in the instrumentedcompilation phase 110 and executed in the instrumented execution phase120. To this effect, in one embodiment, a Cyclic Redundancy Check (CRC)error detection code can be used to check based on the structure andindexes of the CFG of the program. The CRC code in combination with thefunction names can be used to verify the validity of profile data fromcollection to use phase.

FIG. 2B is a flow chart depicting an exemplary computer implementedprocess 250 of profile instrument generation in the instrumentedcompilation phase in accordance with an embodiment of the presentdisclosure. For example, process 250 may be performed by the profilerpass 223 shown in FIG. 2A.

At 251, a CFG is generated. In one embodiment, all the edges of the CFGmay be instrumented. Alternatively, in the illustrated embodiment, aMinimum Spanning Tree (MST)-based approach is adopted to reduceinstrumentation runtime overhead and memory usage. Particularly, an MSTof the CFG for each function is created using static profile data and aunion-find algorithm. At 252, each edge of the MST is instrumented. Ifthe edge is a critical edge, it is split before any instrumentation codecan be added. Profile counts for all basic blocks and edges can bederived from the counts for instrumented edges in the MST. This approachis effective to instrument a significantly reduced number of edges andcan significantly reduce instrumentation runtime overhead and memoryusage because the sum of all incoming edges is the same as the sum ofoutgoing edges.

Since device code is inherently parallel, it is important to ensurememory updates for the instrumentation counters are synchronized. In oneembodiment, atomic instructions (e.g., PTX instructions) are used toachieve atomic update operations. Particularly, each edge in the MST isassociated with atomic profile counter increments at 252.

At 254, the information generated by the profiler pass is written out tothe file “profinfo” which is then included in the front end-processedhost code for supply to the host compiler.

In the instrumented execution phase, the instrumented executable codeenables the host and device processors to coordinate and therebyfacilitate generation and output of profile data. FIG. 2C is a flowchart depicting an exemplary instrumented execution process 260 throughcoordination between a CPU and a GPU in accordance with an embodiment ofthe present disclosure.

In one embodiment, at the beginning of a kernel execution, all thecounters corresponding to the kernel and all the device functions calledfrom it need to be initialized to zero. This trivial issue in asequential program is in-reality more complicated in CUDA. On the deviceside, block-Idx 0,0,0 is guaranteed to be present and execute, but thereis no guarantee on the ordering of this block relative to other blocksin the kernel. Thus, in one embodiment, the host processor may executememory initialization before invocation of the kernel. For safetyreasons, it may set up and initialize the counters for all architecturevariants used during compilation. In the illustrated alternativeembodiment, a GPU driver as executed by the CPU is used to perform theinitialization based on information passed to it using a special sectionin the executable.

The flows in the dashed-boxes 260 and 270 illustrate the CPU (host)execution and GPU (device) execution processes, respectively. Steps261-266 and 271-272 are performed for each kernel invocation at runtime.At 261, the CPU allocates GPU memory for the profile counters of akernel and all the device functions called from the kernel. At 262, theGPU driver is used to initialize the profile counters. At 263, the GPUmemory is bound to an ID of the GPU, e.g., a device symbol name. At 264,the CPU launches the kernel.

In response, the GPU executes the kernel at 271 and increments theprofile counters accordingly at 272. As discussed previously, thecounters associated with a respective code portion are updated each timethe respective code portion is executed at 271. At 265, the CPU copiesthe profile counter values from the GPU memory, and at 266 calls into alibrary (e.g., the NVPGO library) interface to record the collectedprofile information including the counter values. When the executionexits, at 280, the CPU calls the library to write the collected profileinformation to an output file, e.g., the instrumentation output.

FIG. 3A illustrates an exemplary computer implemented process 300 ofoptimization compilation to generate optimized executable code based oncollected profile information in accordance with an embodiment of thepresent disclosure. The program source code is fed to the exemplaryintegrated compiler along with the instrumentation output resulting fromflow 200 in FIG. 2A. Similar with the instrumented compilation process200 in FIG. 2A, the optimization compilation process 300 also involveshost compilation, device compilation, and a linking process. In oneembodiment, the flow in the dashed-line box 310 may be executed for eachcompilation unit in case of separate compilation. In one embodiment, theflow in the dashed-line box 320 may be performed for each virtualarchitecture. However the profiler pass 223 here processes theinstrumentation output to enable code optimization by the profileenhanced optimization passes 227, as described in greater detail withreference to FIG. 3B. The profiler pass 223 and the optimization passes227, in combination, implement the functionalities of profile guideduse. In one embodiment, the resultant optimized device code is thenembedded (e.g., as fat binary images) in the host code and processed bythe host compiler 213 to generate an object file. Eventually, optimizedexecutable code is generated.

FIG. 3B is a flow chart depicting an exemplary computer implementedprocess 350 of processing instrumentation output by the profiler pass223 in the optimization compilation phase in accordance with anembodiment of the present disclosure. At 351, the profiler pass readsthe profile information using the NVPGO library. At 352, the profilerpass sets the instrumented counts for the edges in the MST of eachfunction. At 353, the profiler pass populates the counters for the wholefunction using the instrumented counts. At the end of this step, allbasic blocks and edges in a respective function have been assigned withprofile counts. At 354, the profiler pass adds branch weight metadata toall the conditional branches in the respective function. In oneembodiment, this is done for each function.

In one embodiment, during the optimization compilation phase, theprofile enhanced optimization passes 227 may utilize the profileinformation in accordance with any suitable optimization algorithm thatis well known in the art. After process 350, all the optimization passescan query the profile information to obtain counts for edges and basicblocks. The optimization passes may use algorithms such as Inlining,Global Value Numbering (GVN), Loop-Invariant Code motion (LICM), andLoop unrolling, or any other suitable optimization process that is wellknown in the art.

In one embodiment, the profile information can be passed through theassembly language code (e.g., ptx code) to Optimizing Code Generator(OCG)-enable BBRO, unrolling and spill code placement passes in OCG tomake use of basic block instrumentation information from the profile.

FIG. 4 is a block diagram illustrating an exemplary computing system 500operable to compile integrated source code and thereby generateinstrumented executable code and optimized executable code for devicecode execution in accordance with an embodiment of the presentdisclosure. In one embodiment, system 400 may be a general-purposecomputing device used to compile a program configured to be executedconcurrently by a host processor and one or more device processors inparallel execution system. System 400 comprises a Central ProcessingUnit (CPU) 401, a system memory 402, a Graphics Processing Unit (GPU)403, I/O interfaces 404 and network circuits 405, an operating system406 and application software 407 stored in the memory 402. Software 407includes an exemplary integrated compiler 408 configured to compilesource code having a mixture of host code and device code.

In one embodiment, provided with source code of the program and executedby the CPU 401, the integrated compiler 408 can generate instrumentedexecutable code in an instrumented compilation phase. The instrumentedexecutable code includes: profile instrumentation counters for thedevice functions; and instructions for the host processor to allocateand initialize device memory for the counters and to retrieve collectedprofile information from the device memory to generate instrumentationoutput.

Provided with the instrumentation output, the integrated compiler 408can compile the source code to generate optimized executable code in anoptimized compilation phase for device code execution. The compiler 408includes a profiler pass 409 and one or more optimization passes 410,which are configured to process the instrumentation output (e.g., mapthe profile counters to the device CFG) and optimize the device code.The compiler 409 may perform various other functions that are well knownin the art as well as those discussed in details with reference to FIGS.1-3B.

What is claimed is:
 1. A method comprising: executing instrumentedexecutable code using a host processor in coordination with aco-processor, the executing by the host processor comprising:initializing one or more profile counters that are associated with oneor more portions of the instrumented executable code; causing execution,by the co-processer, of the one or more portions of the instrumentedexecutable code and an update, by the co-processor, to the one or moreprofile counters based on the execution; and retrieving profileinformation that corresponds to the one or more profile counters afterthe update.
 2. The method of claim 1, wherein the host processor is aCentral Processing Unit (CPU) and the co-processor is a GraphicsProcessing Unit (GPU).
 3. The method of claim 1, wherein update includesincrementing the one or more profile counters in atomic operations. 4.The method of claim 1, wherein the executing further comprisesallocating a co-processor memory of the co-processor for the one or moreprofile counters.
 5. The method of claim 1, wherein the one or moreprofile counters are associated with functions of a kernel, and thecausing execution of the one or more portions of the instrumentedexecutable code include invoking the kernel.
 6. The method of claim 1,wherein the retrieving of the profile information includes copying theone or more profile counters from a co-processor memory to a hostprocessor memory.
 7. The method of claim 1, wherein the retrievingincludes the host processor calling a library to write the profileinformation into a file.
 8. The method of claim 1, further comprisingproviding the profile information to a compiler that generatesexecutable code based at least on the profile information.
 9. A methodcomprising: executing instrumented executable code using a co-processorin coordination with a host processor, the executing by the co-processorcomprising: receiving, from the host processor, an initialization of oneor more profile counters that are associated with one or more portionsof the instrumented executable code; executing the one or more portionsof the instrumented executable code based at least on an invocation fromthe host processor; and recording updates to the one or more profilecounters based at least on the executing of the one or more codeportions, wherein by the host processor incorporates the updates to theone or more profile counters into profile information.
 10. The method ofclaim 9, wherein the host processor is a Central Processing Unit (CPU)and the co-processor is a Graphics Processing Unit (GPU).
 11. The methodof claim 9, wherein the recording of the updates includes incrementingthe one or more profile counter in atomic operations during theexecuting of the one or more portions of the instrumented executablecode.
 12. The method of claim 9, wherein the one or more profilecounters are associated with functions of a kernel, and the executing ofthe one or more portions of the instrumented executable code includesrunning the kernel based at least on the invocation from the hostprocessor.
 13. The method of claim 9, wherein the updates to the one ormore profile counters are made in a co-processor memory.
 14. The methodof claim 9, wherein the updates to the one or more profile countersinclude an increment to a profile counter of the one or more profilecounters for each iteration of a plurality of iterations that a portionof the one or more portions of the instrumented executable code that isassigned to the profile counter is executed.
 15. A system comprising: ahost processor; and at least one memory coupled to the host processorand storing at least a portion of instrumented executable code to beexecuted by a Graphics Processing Unit (GPU) and the host processorthat, when executed by the host processor, causes the host processor toperform a method comprising: initializing one or more profile countersassigned to device functions of a kernel of the GPU; invoking thekernel, wherein the GPU updates the one or more profile counters basedat least on execution of the device functions; and retrieving profileinformation that corresponds to the updates to the one or more profilecounters.
 16. The system of claim 15, wherein the method furthercomprises allocating a co-processor memory of the co-processor for theone or more profile counters.
 17. The system of claim 15, wherein theretrieving of the profile information includes copying the one or moreprofile counters from a GPU memory to a host processor memory.
 18. Thesystem of claim 15, wherein the retrieving includes the host processorcalling a library to write the profile information into a file.
 19. Thesystem of claim 15, wherein the method further comprises providing theprofile information to a compiler that generates executable code of theprogram based at least on the profile information.
 20. The system ofclaim 15, wherein the host processor is a Central Processing Unit (CPU).